@extends('install.common.common')
@section('header')
    <li ><a href="javascript:;">环境检测</a></li>
    <li class="active"><a href="javascript:;">参数设置</a></li>
    <li><a href="javascript:;">开始安装</a></li>
    <li><a href="javascript:;">安装完成</a></li>
@endsection
@section('content')
    <div class="col-xs-12 col-sm-8 col-sm-offset-2">
        <div class="panel panel-default">
            <div class="panel-heading">
                <span>参数设置</span>
            </div>
            <div class="panel-body">
                <form  method="post"  id="form" >
                    <h2>数据库连接信息</h2>
                    <div class="form-group">
                        <label class="control-label">数据库连接类型</label>
                        <div class="control-group">
                            <select name="DB_CONNECTION" class="form-control">
                                <option>mysql</option>
                            </select>
                        </div>
                    </div>
                    <div class="form-group">
                        <label class="control-label">数据库服务器，数据库服务器IP，一般为127.0.0.1</label>
                        <div class="control-group">
                            <input class="form-control" type="text" name="DB_HOST" value="127.0.0.1">
                        </div>
                    </div>
                    <div class="form-group">
                        <label class="control-label">数据库名</label>
                        <div class="control-group">
                            <input class="form-control" type="text" name="DB_DATABASE" value="">
                        </div>
                    </div>
                   
                    <div class="form-group">
                        <label class="control-label">数据库用户名</label>
                        <div class="control-group">
                            <input class="form-control" type="text" name="DB_USERNAME" value="root">
                        </div>
                    </div>
                    <div class="form-group">
                        <label class="control-label">数据库密码</label>
                        <div class="control-group">
                            <input class="form-control" type="password" name="DB_PASSWORD" value="">
                        </div>
                    </div>
                    {{csrf_field()}}
                    <input type="submit" class="btn btn-primary btn-block"  value="下一步">
                </form>
                <a class="btn btn btn-default btn-block" href="{{url('/install/step1')}}">上一步</a>
            </div>
            <div class="panel-footer">
            </div>
        </div>
    </div>
    <script type="text/javascript">
        $("#form").submit(function(){
            $.ajax({
                url:"{{url('/install/step3')}}",
                type:"post",
                data:$(this).serialize(),
                success:function(res){
                    if(res.status=='success'){
                        layer.confirm('数据库连接成功,是否安装', {
                            btn: ['是'] //按钮
                        }, function(){
                            window.location.href = "{{url('/install/step4')}}"
                        });
                    }else{
                        layer.msg('连接失败！',{icon:5});
                    }
                }
            });
            return false;
        });

    </script>
@endsection
